

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="John Doe">
  <meta name="keywords" content="">
  
    <meta name="description" content="参考资料：http:&#x2F;&#x2F;dblab.xmu.edu.cn&#x2F;blog&#x2F;1233&#x2F; 注：本篇博文的实验需要一个具有Hadoop集群环境的Docker镜像。@[toc] 运行环境Ubuntu20.04  Hadoop3.3.1 JDK8 1. 使用Docker开启三个容器 本次测试的节点介绍    节点名称 作用    master 主节点   slave1 副节点   slave2 副节点   使用已">
<meta property="og:type" content="article">
<meta property="og:title" content="Hadoop集群搭建 _ 基于Docker搭建3节点的Hadoop完全分布式集群">
<meta property="og:url" content="http://example.com/2021/10/13/Hadoop%E9%9B%86%E7%BE%A4%E6%90%AD%E5%BB%BA%20_%20%E5%9F%BA%E4%BA%8EDocker%E6%90%AD%E5%BB%BA3%E8%8A%82%E7%82%B9%E7%9A%84Hadoop%E5%AE%8C%E5%85%A8%E5%88%86%E5%B8%83%E5%BC%8F%E9%9B%86%E7%BE%A4/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="参考资料：http:&#x2F;&#x2F;dblab.xmu.edu.cn&#x2F;blog&#x2F;1233&#x2F; 注：本篇博文的实验需要一个具有Hadoop集群环境的Docker镜像。@[toc] 运行环境Ubuntu20.04  Hadoop3.3.1 JDK8 1. 使用Docker开启三个容器 本次测试的节点介绍    节点名称 作用    master 主节点   slave1 副节点   slave2 副节点   使用已">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img-blog.csdnimg.cn/00cef19d439846108bf10546de3c8cbb.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/60800bc5b4c7438e820bb9fc100223aa.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/b679c027c4f1417fadf27347ad71616f.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/dd747b76a38041f7afa4e92198474b0c.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/ba0b9c30f869485480dc7dcfe985a0fb.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/536f1d873dc644378bf631b837667f7a.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/8ef8f5cff8a34086a38c18ec8b42e82f.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/97b2cc28d45f46ef9147df191cd0396b.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/3d642f262f2944cfb5ee16d61e102718.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/21f29859cb4149da850198bdac004b7e.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/55590a15963346648df969c2c5f8c82b.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/acf1f1036fbb48c99ba8dbbb3d4eeeb4.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/903619e9ed994ddeb68a8e97e1a75f25.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/bec89e79e8b1451283dcaf4d05eb0871.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/7382239c6e134bbcac19348b4d504045.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/6d44ca5cdff249bc98d6c73782f12fe6.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/01c4988afa1047b98009e12a0cceb2c9.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/0f39728937774f3f91fc0e5bb547e251.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/09691c87fc8a4bed883030286898df6a.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/b1a4e167beed42db95365b8eb945db74.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/4f0e81ecceec45c3adc0020699729180.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/754ccc8f08a24bdeb0d2fb479d3d31dd.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/70710ad17d4c49ffaf88926370449efd.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/4148cdddc7cd43d2824b9e284b25b9d5.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/bbcb399e1f7f4072ba38e8319aa467c3.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/ccfe8ed59191403ab1471a6688fb224e.png">
<meta property="og:image" content="https://img-blog.csdnimg.cn/f4b4fd010e8043c1a3fda9a200f4d084.png">
<meta property="article:published_time" content="2021-10-13T02:01:32.000Z">
<meta property="article:modified_time" content="2022-08-22T15:44:32.236Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="Hadoop">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://img-blog.csdnimg.cn/00cef19d439846108bf10546de3c8cbb.png">
  
  
  
  <title>Hadoop集群搭建 _ 基于Docker搭建3节点的Hadoop完全分布式集群 - Hexo</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.2","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.2.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>尤 Ni&#39;s Blog</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="Hadoop集群搭建 _ 基于Docker搭建3节点的Hadoop完全分布式集群"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        John Doe
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2021-10-13 10:01" pubdate>
          2021年10月13日 上午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          4.5k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          38 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">Hadoop集群搭建 _ 基于Docker搭建3节点的Hadoop完全分布式集群</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：1 小时前
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <p>参考资料：<a target="_blank" rel="noopener" href="http://dblab.xmu.edu.cn/blog/1233/">http://dblab.xmu.edu.cn/blog/1233/</a></p>
<p>注：本篇博文的实验需要一个具有Hadoop集群环境的Docker镜像。<br>@[toc]</p>
<h1 id="运行环境"><a href="#运行环境" class="headerlink" title="运行环境"></a>运行环境</h1><p>Ubuntu20.04 </p>
<p>Hadoop3.3.1</p>
<p>JDK8</p>
<h1 id="1-使用Docker开启三个容器"><a href="#1-使用Docker开启三个容器" class="headerlink" title="1. 使用Docker开启三个容器"></a>1. 使用Docker开启三个容器</h1><hr>
<p><img src="https://img-blog.csdnimg.cn/00cef19d439846108bf10546de3c8cbb.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br>本次测试的节点介绍</p>
<table>
<thead>
<tr>
<th>节点名称</th>
<th>作用</th>
</tr>
</thead>
<tbody><tr>
<td>master</td>
<td>主节点</td>
</tr>
<tr>
<td>slave1</td>
<td>副节点</td>
</tr>
<tr>
<td>slave2</td>
<td>副节点</td>
</tr>
</tbody></table>
<p>使用已具有Hadoop集群环境的镜像创建容器、一个终端负责控制一个容器</p>
<blockquote>
<p>主节点</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">sudo docker run -it -h master --name master ubuntu/hadoop<br></code></pre></td></tr></table></figure>

<blockquote>
<p>副节点1</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">sudo docker run -it -h slave1 --name slave1 ubuntu/hadoop<br></code></pre></td></tr></table></figure>

<blockquote>
<p>副节点2</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">sudo docker run -it -h slave2 --name slave2 ubuntu/hadoop<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/60800bc5b4c7438e820bb9fc100223aa.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h1 id="2-配置ip映射-测试ssh"><a href="#2-配置ip映射-测试ssh" class="headerlink" title="*2. 配置ip映射 测试ssh"></a>*2. 配置ip映射 测试ssh</h1><hr>
<p>接下来的操作需对三个节点同时进行</p>
<p>每次容器重新启动后都需要配置hosts</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">vim etc/hosts<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/b679c027c4f1417fadf27347ad71616f.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<p>根据查询可知，三个节点的IP信息如下表所示：</p>
<table>
<thead>
<tr>
<th>节点名称</th>
<th>映射的IP</th>
</tr>
</thead>
<tbody><tr>
<td>master</td>
<td>172.17.0.2</td>
</tr>
<tr>
<td>slave1</td>
<td>172.17.0.3</td>
</tr>
<tr>
<td>slave2</td>
<td>172.17.0.4</td>
</tr>
</tbody></table>
<p>为了使他们三个节点能互相连接，需要在每个的配置文件里加上另外两个的IP，如下图所示<br><img src="https://img-blog.csdnimg.cn/dd747b76a38041f7afa4e92198474b0c.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<p>修改好后保存退出</p>
<blockquote>
<p> 测试SSH</p>
</blockquote>
<p>以Master节点为例，如果它能连接slave1和slave2，说明ssh功能完好（对slave1、slave2执行同样的操作，这里略过）</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs shell">ssh slave1<br><br>exit<br><br>ssh slave2<br><br>exit<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/ba0b9c30f869485480dc7dcfe985a0fb.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br><img src="https://img-blog.csdnimg.cn/536f1d873dc644378bf631b837667f7a.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h1 id="3-修改Hadoop的配置文件"><a href="#3-修改Hadoop的配置文件" class="headerlink" title="3. 修改Hadoop的配置文件"></a>3. 修改Hadoop的配置文件</h1><hr>
<p>搭建Hadoop集群需要修改的配置文件有如下3个。因为已经开启了3个节点，这里采取的策略是先在master节点修改好配置文件，接着将该所有配置文件使用 cp命令复制到其他两个节点的对应目录下。注：表示集群节点的配置文件(workers) 需要单独修改</p>
<p>文件都在 .&#x2F;etc&#x2F;hadoop 的位置</p>
<ul>
<li><code>hadoop-env.sh</code> 配置Hadoop运行相关的环境变量，比如设置JDK路径、集群各个进程的用户等等</li>
<li><code>core-site.xml</code>设置hadoop临时目录、HDFS的远程地址</li>
<li><code>hdfs-site.xml</code> 对于HDFS，名称&#x2F;数据节点存放位置、文件副本个数等</li>
<li><code>mapred-site.xml</code> 设置MapReduce参数</li>
<li><code>yarn-site.xml</code> 配置集群资源管理系统参数</li>
<li><code>workers</code> 指定集群中工作的副节点</li>
</ul>
<p>修改配置时，只添加内容，其他内容原封不变。</p>
<h2 id="3-1-hadoop-env-sh"><a href="#3-1-hadoop-env-sh" class="headerlink" title="3.1 hadoop-env.sh"></a>3.1 hadoop-env.sh</h2><hr>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs sh"><span class="hljs-built_in">export</span> JAVA_HOME=/usr/local/jdk8<br><span class="hljs-built_in">export</span> HDFS_NAMENODE_USER=root<br><span class="hljs-built_in">export</span> HDFS_DATANODE_USER=root<br><span class="hljs-built_in">export</span> HDFS_SECONDARYNAMENODE_USER=root<br><span class="hljs-built_in">export</span> YARN_RESOURCEMANAGER_USER=root<br><span class="hljs-built_in">export</span> YARN_NODEMANAGER_USER=root<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/8ef8f5cff8a34086a38c18ec8b42e82f.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="3-2-core-site-xml"><a href="#3-2-core-site-xml" class="headerlink" title="3.2 core-site.xml"></a>3.2 core-site.xml</h2><hr>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">configuration</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>hadoop.tmp.dir<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>file:/usr/local/hadoop/tmp<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">description</span>&gt;</span>Abase for other temporary directories.<span class="hljs-tag">&lt;/<span class="hljs-name">description</span>&gt;</span><br> <span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br> <span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>fs.defaultFS<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>hdfs://master:9000<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">configuration</span>&gt;</span><br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/97b2cc28d45f46ef9147df191cd0396b.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="3-3-hdfs-site-xml"><a href="#3-3-hdfs-site-xml" class="headerlink" title="3.3 hdfs-site.xml"></a>3.3 hdfs-site.xml</h2><hr>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span> <br>        <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>dfs.namenode.name.dir<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>file:/usr/local/hadoop/namenode_dir<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>dfs.datanode.data.dir<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>file:/usr/local/hadoop/datanode_dir<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>dfs.replication<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>3<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span> <br><span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/3d642f262f2944cfb5ee16d61e102718.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="3-4-mapred-site-xml"><a href="#3-4-mapred-site-xml" class="headerlink" title="3.4 mapred-site.xml"></a>3.4 mapred-site.xml</h2><hr>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">configuration</span>&gt;</span><br>         <span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>mapreduce.framework.name<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>yarn<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br>     <br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>yarn.app.mapreduce.am.env<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>HADOOP_MAPRED_HOME=/usr/local/hadoop<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>mapreduce.map.env<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>HADOOP_MAPRED_HOME=/usr/local/hadoop<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>mapreduce.reduce.env<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>HADOOP_MAPRED_HOME=/usr/local/hadoop<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">configuration</span>&gt;</span><br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/21f29859cb4149da850198bdac004b7e.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="3-5-yarn-site-xml"><a href="#3-5-yarn-site-xml" class="headerlink" title="3.5 yarn-site.xml"></a>3.5 yarn-site.xml</h2><hr>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">configuration</span>&gt;</span><br><br><span class="hljs-comment">&lt;!-- Site specific YARN configuration properties --&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span>    <br>        <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>yarn.nodemanager.aux-services<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>mapreduce_shuffle<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span> <br><span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span> <br><br><span class="hljs-tag">&lt;<span class="hljs-name">property</span>&gt;</span> <br>        <span class="hljs-tag">&lt;<span class="hljs-name">name</span>&gt;</span>yarn.resourcemanager.hostname<span class="hljs-tag">&lt;/<span class="hljs-name">name</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">value</span>&gt;</span>master<span class="hljs-tag">&lt;/<span class="hljs-name">value</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">property</span>&gt;</span><br>    <br><span class="hljs-tag">&lt;/<span class="hljs-name">configuration</span>&gt;</span><br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/55590a15963346648df969c2c5f8c82b.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<p>至此，已修改好了统一的配置文件，接下来可以把master节点的配置目录复制到其他节点</p>
<p><img src="https://img-blog.csdnimg.cn/acf1f1036fbb48c99ba8dbbb3d4eeeb4.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="3-6-workers"><a href="#3-6-workers" class="headerlink" title="3.6 workers"></a>3.6 workers</h2><hr>
<blockquote>
<p>该配置文件负责设置Hadoop集群的从节点</p>
</blockquote>
<p><img src="https://img-blog.csdnimg.cn/903619e9ed994ddeb68a8e97e1a75f25.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="3-6-复制配置文件"><a href="#3-6-复制配置文件" class="headerlink" title="3.6 复制配置文件"></a>3.6 复制配置文件</h2><hr>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">scp -rq /usr/local/hadoop/etc/hadoop root@slave1:/usr/local/hadoop/etc/<br>scp -rq /usr/local/hadoop/etc/hadoop root@slave2:/usr/local/hadoop/etc/<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/bec89e79e8b1451283dcaf4d05eb0871.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="3-7-检验配置文件是否复制成功"><a href="#3-7-检验配置文件是否复制成功" class="headerlink" title="3.7 检验配置文件是否复制成功"></a>3.7 检验配置文件是否复制成功</h2><hr>
<p>分别在 slave1和slave2节点检验</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs shell">cat /usr/local/hadoop/etc/hadoop/yarn-site.xml<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/7382239c6e134bbcac19348b4d504045.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<p>出现配置信息则说明拷贝成功</p>
<h1 id="4-启动-Hadoop集群"><a href="#4-启动-Hadoop集群" class="headerlink" title="4. 启动 Hadoop集群"></a>4. 启动 Hadoop集群</h1><hr>
<h2 id="4-1-Master节点初始化名称节点"><a href="#4-1-Master节点初始化名称节点" class="headerlink" title="4.1 Master节点初始化名称节点"></a>4.1 Master节点初始化名称节点</h2><hr>
<blockquote>
<p>该操作只有在第一次启动集群时执行，之后再次启动集群无需初始化，否则会出错</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">cd /usr/local/hadoop<br>bin/hdfs namenode -format<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/6d44ca5cdff249bc98d6c73782f12fe6.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="4-2-在Master节点启动集群"><a href="#4-2-在Master节点启动集群" class="headerlink" title="4.2 在Master节点启动集群"></a>4.2 在Master节点启动集群</h2><hr>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">cd /usr/local/hadoop<br>sbin/start-all.sh<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/01c4988afa1047b98009e12a0cceb2c9.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="4-3-JPS-查询结果"><a href="#4-3-JPS-查询结果" class="headerlink" title="4.3 JPS 查询结果"></a>4.3 JPS 查询结果</h2><hr>
<p>分别在三个节点输入 <code>jps</code> 命令查询当前的进程</p>
<p>若启动正常，各节点进程情况如下：</p>
<table>
<thead>
<tr>
<th>节点名称</th>
<th>进程个数</th>
<th>进程名</th>
</tr>
</thead>
<tbody><tr>
<td>master</td>
<td>4</td>
<td>Jps、ResourceManager、SecondaryNameNode、NameNode</td>
</tr>
<tr>
<td>slave1</td>
<td>3</td>
<td>Jps、DataNode、NodeManager</td>
</tr>
<tr>
<td>slave2</td>
<td>3</td>
<td>Jps、Datanode、NodeManager</td>
</tr>
</tbody></table>
<p><img src="https://img-blog.csdnimg.cn/0f39728937774f3f91fc0e5bb547e251.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="4-4-通过Web访问集群"><a href="#4-4-通过Web访问集群" class="headerlink" title="4.4 通过Web访问集群"></a>4.4 通过Web访问集群</h2><hr>
<p>URL: masterIp:8088&#x2F;cluster</p>
<p>我这里的地址是 <a target="_blank" rel="noopener" href="http://172.17.0.2:8088/cluster">http://172.17.0.2:8088/cluster</a></p>
<p><img src="https://img-blog.csdnimg.cn/09691c87fc8a4bed883030286898df6a.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h1 id="5-运行分布式实例"><a href="#5-运行分布式实例" class="headerlink" title="5. 运行分布式实例"></a>5. 运行分布式实例</h1><hr>
<blockquote>
<p>接下来的操作均在 Master节点进行</p>
</blockquote>
<h2 id="5-1-在HDFS创建用户目录"><a href="#5-1-在HDFS创建用户目录" class="headerlink" title="5.1 在HDFS创建用户目录"></a>5.1 在HDFS创建用户目录</h2><hr>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs shell">cd /usr/local/hadoop/bin<br>./hdfs dfs -mkdir -p /user/hadoop/input<br>./hdfs dfs -ls /user/hadoop<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/b1a4e167beed42db95365b8eb945db74.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="5-2-上传本地hadoop配置文件到HDFS"><a href="#5-2-上传本地hadoop配置文件到HDFS" class="headerlink" title="5.2 上传本地hadoop配置文件到HDFS"></a>5.2 上传本地hadoop配置文件到HDFS</h2><hr>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs shell">cd /usr/local/hadoop/bin<br>./hdfs dfs -put /usr/local/hadoop/etc/hadoop/*.xml /user/hadoop/input<br>./hdfs dfs -ls /user/hadoop/input<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/4f0e81ecceec45c3adc0020699729180.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<p>上传后可在外部通过web查询集群状态</p>
<p><a target="_blank" rel="noopener" href="http://172.17.0.2:8088/cluster/nodes">http://172.17.0.2:8088/cluster/nodes</a></p>
<p><img src="https://img-blog.csdnimg.cn/754ccc8f08a24bdeb0d2fb479d3d31dd.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="5-3-运行-MapReduce-作业"><a href="#5-3-运行-MapReduce-作业" class="headerlink" title="5.3 运行 MapReduce 作业"></a>5.3 运行 MapReduce 作业</h2><hr>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">cd /usr/local/hadoop/bin<br>./hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar grep /user/hadoop/input /user/hadoop/output &#x27;dfs[a-z.]+&#x27;<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/70710ad17d4c49ffaf88926370449efd.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"><br><img src="https://img-blog.csdnimg.cn/4148cdddc7cd43d2824b9e284b25b9d5.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<p><img src="https://img-blog.csdnimg.cn/bbcb399e1f7f4072ba38e8319aa467c3.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<h2 id="5-4-查询结果"><a href="#5-4-查询结果" class="headerlink" title="5.4 查询结果"></a>5.4 查询结果</h2><hr>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">cd /usr/local/hadoop/bin<br>./hdfs dfs -cat /user/hadoop/output/*<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/ccfe8ed59191403ab1471a6688fb224e.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>
<p>至此，若出现上图结果，则说明执行成功！</p>
<h1 id="6-关闭集群"><a href="#6-关闭集群" class="headerlink" title="6.关闭集群"></a>6.关闭集群</h1><hr>
<blockquote>
<p>以下操作只需在 Master节点上执行</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell">cd /usr/local/hadoop/sbin<br>./stop-all.sh<br></code></pre></td></tr></table></figure>
<p><img src="https://img-blog.csdnimg.cn/f4b4fd010e8043c1a3fda9a200f4d084.png" srcset="/img/loading.gif" lazyload alt="在这里插入图片描述"></p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E5%A4%A7%E6%95%B0%E6%8D%AE/" class="category-chain-item">大数据</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/Hadoop/">#Hadoop</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>Hadoop集群搭建 _ 基于Docker搭建3节点的Hadoop完全分布式集群</div>
      <div>http://example.com/2021/10/13/Hadoop集群搭建 _ 基于Docker搭建3节点的Hadoop完全分布式集群/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>John Doe</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2021年10月13日</div>
        </div>
      
      
      <div class="license-meta-item">
        <div>许可协议</div>
        <div>
          
            
            
              <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
              <span class="hint--top hint--rounded" aria-label="BY - 署名">
                <i class="iconfont icon-by"></i>
              </span>
              </a>
            
          
        </div>
      </div>
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2021/10/13/JavaWeb%20_%20%E5%AE%9E%E7%8E%B0%E7%AE%80%E5%8D%95%E7%99%BB%E9%99%86%E7%9A%84%E4%B8%A4%E7%A7%8D%E6%96%B9%E5%BC%8F%20_%20Servlet%20%E5%92%8C%20JQuery%20Ajax/" title="JavaWeb _ 实现简单登陆的两种方式 _ Servlet 和 JQuery Ajax">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">JavaWeb _ 实现简单登陆的两种方式 _ Servlet 和 JQuery Ajax</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2021/10/13/%E3%80%90Hadoop%E3%80%91%E5%9F%BA%E4%BA%8EDocker%E6%90%AD%E5%BB%BA%E9%9B%86%E7%BE%A4%E7%8E%AF%E5%A2%83/" title="【Hadoop】基于Docker搭建集群环境">
                        <span class="hidden-mobile">【Hadoop】基于Docker搭建集群环境</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      headingSelector : CONFIG.toc.headingSelector || 'h1,h2,h3,h4,h5,h6',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      collapseDepth   : CONFIG.toc.collapseDepth || 0,
      scrollSmooth    : true,
      headingsOffset  : -boardTop
    });
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.10/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
